<?php


namespace app\api\controller;

use think\Controller;
use think\Db;
use think\Log;
use think\Request;

class Info extends Controller
{
    
    public function __construct()
    {
        header('Content-Type: text/html;charset=utf-8');
        header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求
        header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE'); // 允许请求的类型
        header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies
        header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin'); // 
        // parent::__construct();
        // set_cors();
    }

    public function content(){
        $params = Request::instance()->param();
        $res = Db::connect('db_config2')->table('server_config_info')->where(['ServerName'=>'PayUrl'])->find();

        // $json_string = file_get_contents(env('PLATFORM.Pay_url'));
        $json_string = $res['Content'];
        $data = json_decode($json_string,true);
        
        $array = [
            '-1'=>$data[-1],
            $params['channel']=>empty($data[$params['channel']])?'':$data[$params['channel']]
        ];
        exit(json_encode($array));
    }

   
    

    
}

